/**
 * @Author bian
 * @CreateDate 2017.3.2
 */

import "../base.js"
import {AJAXERROR,errorHandler} from "../Error"

export const GETCOURSES = "GETCOURSES"
export const FILTER = "FILTER"
export const SORT = "SORT"
export const CHANGEPAGE = "CHANGEPAGE"

/**
 * 得到课程列表
 */
export function getCourses(){
    var courses = document.getElementById("coursesData").innerText
    courses = JSON.parse(courses)
    return {
        type : GETCOURSES,
        courses : courses
    }
}


/**
 * 按方向筛选
 * @param major
 * @returns {{type: string, major: *}}
 */
export function filterCourse(major){
    return {
        type : FILTER,
        major
    }
}

/**
 * 根据最新或最热排序课程
 * @param gist 依据
 * @returns {{type: string}}
 */
export function sortCourse(gist){
    return {
        type : SORT,
        gist
    }
}

/**
 * 改变页数
 */
export function changePage(page){
    return {
        type : CHANGEPAGE,
        page
    }
}